<?php
//------------------------------------------------------------------------------
// File               : V_TintucList
// Modification       :
//------------------------------------------------------------------------------
// Date(yyyy.mm.dd)   Developer                       Action
//------------------------------------------------------------------------------
// 2007.03.15         Oanhhtk                         Created
//------------------------------------------------------------------------------

function V_TintucList(&$arrayData){
	global $LANG;
    $ulr = "?".MODUL."=tintuc&".ACTION."=";
?>
<?= CM_showError() ?> 
<?
    //phan trang
	$totalRows = 0;
	$curPage =1;
	$strStart =0;
	$strEnd=0;
	
	$totalRows=count($arrayData);
	$totalRecord = NUM_ROW_SP;
	
	$curPage =CM_getParameter("curPg");
	if(((int)$curPage)==0) $curPage =1;
	
	$totalPage = 	(int)($totalRows/$totalRecord);
	if($totalRows % $totalRecord > 0 ) $totalPage ++;
	
	if($totalRows >0){
		$strStart = ($curPage -1) * $totalRecord+1;
		$strEnd   = ($curPage )   * $totalRecord ;
		if($strEnd  > $totalRows ) $strEnd  = $totalRows;
	}
?>	

<script>
function GotoPage(iPage) 
{
    document.frm.curPg.value=iPage;
	document.frm.action = "../run/main.php?modul=tintuc&action=<?=$action?>&curPage="+iPage;
    document.frm.submit()  ;
}
</script>
<div class="title" style="margin-left:10px; width:10px; height:30px; float:left"></div><p style="float:left; line-height:30px; font-weight:bold; color:#FFFFFF; background: url(../images/modul_c.gif)">Tin tức</p><div class="title2" style="width:10px; height:30px; float:left"></div><div style="clear:both"></div>
	<div class="bg_l_t"><div class="bg_r_t"><div class="bg_c_t"></div></div></div>
<table width="100%" cellpadding="0" cellspacing="0" class="khung_home">
<form name="frm" action=""  method="post" >
	<?
		if(!empty($arrayData)){
			$curRow=0;
			$i=0;
			foreach($arrayData as $row){
				$curRow ++;
				if( $curRow < $strStart ) continue;
				if( $curRow > $strEnd )  break;
				$i=+1;
				
				
	?>
		<tr>
			<td style="padding-bottom:5px;">
				<a href="?modul=tintuc&action=View&id=<?=$row['id']?>" class="title_content" ><?=$row['tieu_de']?></a>
			</td>
		</tr>
		<tr>
			<td align="justify" style="line-height:18px; padding-right:10px;">
				<?
				if(($row["anh"])!=""){
				?>
				<a  href="<?=$ulr?>View&id=<?=$row['id']?>">
				<img id="image" src="<?=DIR_IMAGES_VIEW.$row['anh']?>" width="130" style="padding-right:8px; " align="left" border="0">
				</a>
				<font  style=" font-size:11px; font-family:tahoma; line-height:18px;  text-align:justify; padding-right:5px;">
				<?=$row["tom_tat"]?>
				</font>
				<?
				}else{
				?>
				<font  style=" font-size:11px; font-family:tahoma; line-height:18px;  text-align:justify; padding-right:5px;">
				<?=$row["tom_tat"]?>
				</font>
				<?
				}
				?>
			</td>
		</tr>
		<tr>
			<td align="right" style="padding-right:5px; padding-top:5px; ">
				<a href="?modul=tintuc&action=View&id=<?=$row['id']?>" style="color:#007DEB; font-family:tahoma; font-size:11px; ">
				Xem tiếp <img src="../images/chitiet_list.png">
				</a>
			</td>
		</tr>
		
		<?
		if( $curRow < $strEnd ){
		?>
		<tr>
			<td style="padding-right:5px; ">
				<hr style="border-bottom:0.1em solid #FF0000;" />
			</td>
		</tr>
		<?
		}
		?>
		<tr>
			<td style="padding-top:5px; "></td>
		</tr>
		
	<?
			
				
			}// end foreach
		
				
	?>
		<tr>
		<td colspan="3" style="padding-top:20px; ">
			<?
			if($totalPage>1){	
			?>
			<table  cellpadding="0" cellspacing="0" align="center">
				<br>
				<tr>
					<td class="pagingIntact">
						<a href="javascript:GotoPage('1')">&nbsp;&laquo;&nbsp;Trang đầu&nbsp;</a>
					</td>
					<td class="pagingSpace"></td>
					<?
					for($i=1;$i<= $totalPage;$i++){
						if($i < $curPage + 11 && $i > $curPage - 11){
							if($i == $curPage){
					?>
					<td class="pagingViewed">
						<?=$i?>
					</td>
					<td class="pagingSpace"></td>
					<?
							}
							if($i != $curPage){
					?>
					<td class="pagingIntact">
						<a href="javascript:GotoPage('<?=$i?>')"><?=$i?></a>
					</td>
					<td class="pagingSpace"></td>
					<?
							}
						} 
					}
					?>
					<td class="pagingIntact">
						<a href="javascript:GotoPage('<?=$totalPage?>')">&nbsp;Trang cuối&nbsp;&raquo;&nbsp;</a>
					</td>
				</tr>
			</table>
			<?
			}//end if($totalPage>1)
			?>
		</td>
	</tr>
	<?
		}
	?>
<input type=hidden  name="curPg"  value="0" >
<input type=hidden  name="id"  value="<?=CM_getParameter('id')?>" >
<input type=hidden  name="textfield"  value="<?=CM_getParameter('textfield')?>" >
</form>		
</table>
<div class="bg_l_b"><div class="bg_r_b"><div class="bg_c_b"></div></div></div>



<?php
foreach ($_POST as $key => $value) {
		$value = htmlspecialchars( CM_getParameter($key));
		echo '<input type=hidden  name="'.$key.'"  value="'.$value.'" >';
		echo "\n";
	}
}
?>